/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package backingBean;

import entities.Members;
import javaServices.MemberManager;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author michael
 */
@ManagedBean(name="register")
@RequestScoped
public class RegisterMB {
    
    private Members members;

    @PostConstruct
    public void initData(){
        members = new Members();
    }
    
    public Members getMembers() {
        return members;
    }

    public void setMembers(Members members) {
        this.members = members;
    }
    
    public String registerUser(){
        members.setIsActive(1);
        members.setMembershipID(1);
        MemberManager.insertUser(members);
        
        FacesContext context = FacesContext.getCurrentInstance();
        context.getExternalContext().getSessionMap().put("member", members);
        
        return "profile";
    }
}
